<?php
namespace app\adminapi\controller\v1\setting;

use app\adminapi\controller\AuthController;
use app\services\system\config\SystemConfigRawardServices;
use think\facade\App;

/**
 * 系统配置
 * Class SystemConfig
 * @package app\adminapi\controller\v1\setting
 */
class SystemConfigRaward extends AuthController
{
 /**
     * SystemConfig constructor.
     * @param App $app
     * @param SystemConfigRawardServices $services
     */
    public function __construct(App $app, SystemConfigRawardServices $services)
    {
        parent::__construct($app);
        $this->services = $services;
    }

    public function index($codeType = 1){
       $where["code_type"] = $codeType;
       $where["is_show"] = 1;
       $count  = $this->services->count( $where);
       $result = $this->services->selectList($where);
       return app('json')->success(["total"=>$count,"data"=>$result]);
    }

    public function save(){
        $data = $this->request->postMore([
            ['ordinary_points_convert', 0],
            ['premium_points_convert', 0],
            // ['dividend_ratio', 0],
        ]);
        foreach($data as $key=>$val){
           $this->services->update($key,["code_value"=>$val],"code");
        }
        return app('json')->success(100000);
     }
}